import axios from '@/utils/request'

const ApiUrl = '/admin_api/attraction/attractions'
const Firmware = '/admin_api/v1/firmware'

/**
 * @description: 景区列表
 */
export function getList(params) {
  return axios.get(`${ApiUrl}/`, {
    params
  })
}

/**
 * @description: 删除景区
 */
export function del(id) {
  return axios.delete(`${ApiUrl}/${id}/`)
}

/**
 * @description: 获取景区详情
 */
export function getDetail(id) {
  return axios.get(`${ApiUrl}/${id}/`)
}

/**
 * @description: 添加景区
 */
export function add(data) {
  return axios.post(`${ApiUrl}/`, data)
}

/**
 * @description: 修改景区
 */
export function edit(id, data) {
  return axios.put(`${ApiUrl}/${id}/`, data)
}

/**
 * @description: 语音文件夹列表
 * init_status: 初始化状态 1. not_process: 未执行 2. processing: 执行中 3. success: 执行成功 4. fail: 执行失败
 */
export function getFirmwareList(params) {
  return axios.get(`${Firmware}/attraction_voice_dirs/`, {
    params
  })
}

/**
 * @description: 创建语音文件夹
 */
export function addFirmware(data) {
  return axios.post(`${Firmware}/add_voice_dir/`, data)
}

/**
 * @description: 删除语音文件夹
 */
export function delFirmware(dir_id) {
  return axios.post(`${Firmware}/delete_voice_dir/`, { dir_id })
}

/**
 * @description: 发布语音文件夹
 */
export function publishFirmware(data) {
  return axios.post(`${Firmware}/publish_voice_file/`, data)
}

/**
 * @description: 景点语音列表
 */
export function getFileList(params) {
  return axios.get(`${Firmware}/attraction_voice_files/`, {
    params
  })
}

/**
 * @description: 删除语音文件
 */
export function delFile(file_id) {
  return axios.post(`${Firmware}/delete_voice_file/`, { file_id })
}

/**
 * @description: 上传语音压缩包
 */
export function initAttractionVoice(data) {
  return axios.post(`${Firmware}/init_attraction_voice/`, data)
}
/**
 * @description: 替换语音压缩包
 */
export function updateVoiceDir(data) {
  return axios.post(`${Firmware}/replace_voice_dir/`, data)
}

/**
 * @description: 更新固件信息
 * @return {*}
 */
export const update = `${Firmware}/update/`

/**
 * @description: 新增语音文件
 * @return {*}
 */
export const addVoiceFile = `${Firmware}/add_voice_file/`

/**
 * @description: 获取导入列表
 * @param {*} params
 * @return {*}
 */
export function getUploadList(params) {
  return axios.get(`/admin_api/attraction/view_list`, {
    params
  })
}

/**
 * @description: 导入语音文件
 * @param {*} data
 * @return {*}
 */

export const importVoiceFile = `/admin_api/attraction/view_import/`

/**
 * @description: 景点视图统计
 * @param {*} params
 * @return {*}
 */
export function getAttractionStats(params) {
  return axios.get(`/admin_api/stats/attraction_view_num_stats/`, {
    params
  })
}

/**
 * @description: 景点视图排名统计
 * @param {*} params
 * @return {*}
 */
export function getAttractionRankStats(params) {
  return axios.get(`/admin_api/stats/attraction_view_rank_stats/`, {
    params
  })
}
